<?php 
namespace Home\Model;
use Think\Model;
class UserModel extends Model {
	
	public function checkEmail($email)
	{
		$res = $this->where("email='{$email}'")->find();

		// $sql  = "select * from user where email='{$email}'";//原始的方法

		// $res = $this->query($sql);

		// var_dump($res);
		return $res;
	}
	
	public function checkNickname($nickname)
	{
		$res = $this->where("nickname='{$nickname}'")->find();
		// var_dump($res);

		return $res;
	}
	public function checkLogin($email,$password){
		$password=md5($password);//把密码转换为md5密码
		//方法一(原始方法)
		// $sql="select * from user where email='{$email}' and password='{$password}'";
		// $res=$this->query($sql);
		// var_dump($res);
		//方法二
		$data=array(
			'email'=>$email,  //$email变量不能用引号包起来，记住啦
			'password'=>$password
			);
		return $this->where($data)->find();

	}

}


 ?>